import { BaseHttpService } from "../../shared/services/baseHttp.service";
import { Injectable } from "@angular/core";
import { HttpClient, HttpParams } from "@angular/common/http";
import { Observable } from "rxjs";
import { ClientReportModel } from "./models/clientReport.model";
import { AccountInfoModel } from "./models/accountInfo.model";

@Injectable()
export class FtpReportsService extends BaseHttpService {
    constructor(private http: HttpClient) {
        super();
    }

    public getFtpClientReport(accountId: string): Observable<ClientReportModel[]> {
        return this.http.get<ClientReportModel[]>(this.serverUrl + 'reportftpserv/api/v1/ftpclientreport/account/' + accountId);
    }

    public getFtpAccountInfo(accountId: string): Observable<AccountInfoModel> {
        return this.http.get<AccountInfoModel>(this.serverUrl + 'reportftpserv/api/v1/ftpaccountinfo/account/' + accountId);
    }

    //use any because call returns a lot of info
    public getAdminFilters(accountId: string): Observable<any[]> {
        return this.http.get<any[]>(this.serverUrl + 'screeningtoolserv/api/v1/filters/adminfilters/' + accountId);
    }

    public saveAccountInfo(accountInfo: AccountInfoModel): Observable<void> {
        return this.http.post<void>(this.serverUrl + 'reportftpserv/api/v1/ftpaccountinfo/', accountInfo);
    }

    public saveReport(report: ClientReportModel, edit: boolean): Observable<void>{
        if(edit == false)
            return this.http.post<void>(this.serverUrl + 'reportftpserv/api/v1/ftpclientreport/', report);
        else
            return this.http.put<void>(this.serverUrl + 'reportftpserv/api/v1/ftpclientreport/', report);
    }

    public deleteReport(accountId: string, reportId: string): Observable<void> {
        return this.http.delete<void>(this.serverUrl + 'reportftpserv/api/v1/ftpclientreport/account/' + accountId + '/reportId/' + reportId);
    }
}